package cn.ekuma.epos.datalogic.local;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import cn.ekuma.epos.datalogic.local.dao.ProductDAO;
import cn.ekuma.epos.datalogic.local.erp.dao.FindOrdersInfoDAO;

public class LocalERPDBHelper extends SQLiteOpenHelper {
	
	private static final int DB_VERSION = 5;
	private static final String DB_NAME = "e_pos_erp_local.db"; 

	ProductDAO productDAO;
	FindOrdersInfoDAO findOrdersInfoDAO;
	
	public LocalERPDBHelper(Context context) {
		    super(context, DB_NAME, null, DB_VERSION);
		    productDAO=new ProductDAO(this);
		    findOrdersInfoDAO=new FindOrdersInfoDAO(this);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		ProductDAO.onCreate(db);
		FindOrdersInfoDAO.onCreate(db);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		productDAO.onUpgrade(db, oldVersion, newVersion);
		findOrdersInfoDAO.onUpgrade(db, oldVersion, newVersion);
		onCreate(db);
	}
}
